//
//  AJSpriteNode.swift
//  SpriteKitDemo
//
//  Created by lizhijun on 2023/4/21.
//

import UIKit
import SpriteKit
class AJSpriteNode: SKSpriteNode {
    private var hitCount = 0
    private(set)  var contentView :NodeContentView? = NodeContentView()
    
    //当Mark == 100是创建GIF
    var mark:Int8 = 0{
        didSet{
            if mark == 100{
                //玩家的mark为100
                contentView?.stopClosure = {
                    [weak self] in
                    guard let self = self else {
                        return
                    }
                    self.hitCount = 0
                }
                contentView?.setupGIF()
            }
        }
    }
    
    //中弹的处理
    func getshot(){
        if hitCount < 3{
            hitCount += 1
            return
        }
        contentView?.playGIf()
    }
    
    
    
    func removeContentView(){
        self.contentView?.removeFromSuperview()
        contentView = nil
    }
}


